<template>
  <a-card :bordered="false" style="margin-bottom: 10px">
    <z-table ref="table" rowKey="id" :showAlert="false" :showSelection="false" :loading="loading" :columns="columns"
             :dataSource="pageData" @change="onTableChange">
      <template slot="time" slot-scope="text,record">
        <span v-if="record.intStartTime == null">--</span>
        <span v-else>{{ record.intStartTime }} ~ {{ record.intEndTime }}</span>
      </template>
      <template slot="converConClassification" slot-scope="text,record">
        <span v-if="text == null">{{ record.interviewClassification }}</span>
        <span v-else>{{ text }}</span>
      </template>
      <template slot="interviewNum" slot-scope="text">
        <span>第 {{ text }} 次</span>
      </template>
      <template slot="isNotice" slot-scope="text">
        <span v-if="text == null">--</span>
        <span v-if="text == '1'">已通知</span>
        <span v-if="text == '2'">未通知</span>
      </template>
      <template slot="status" slot-scope="text">
        <span v-if="text == '1'">待录入</span>
        <span v-if="text == '2'">已完成</span>
        <span v-if="text == '3'">已取消</span>
      </template>
      <!--操作-->
    </z-table>
  </a-card>
</template>

<script>
import * as educationTalk from '@/api/sjsk/help/educationTalk.js'
import BaseInfo from '@/views/sjsk/modules/BaseInfo'
export default {
  components: {},

  data() {
    return {
      loading: false,
      columns: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '访谈次数',
          dataIndex: 'interviewNum',
          align: 'center',
          scopedSlots: { customRender: 'interviewNum' },
        },
        {
          title: '访谈分类',
          dataIndex: 'converConClassification',
          align: 'center',
          scopedSlots: { customRender: 'converConClassification' },
        },
        {
          title: '预约时间',
          dataIndex: 'time',
          align: 'center',
          scopedSlots: { customRender: 'time' },
        },
        {
          title: '通知状态',
          dataIndex: 'isNotice',
          align: 'center',
          scopedSlots: { customRender: 'isNotice' },
        },
        {
          title: '录入状态',
          dataIndex: 'status',
          align: 'center',
          scopedSlots: { customRender: 'status' },
        },
        {
          title: '谈话时间',
          dataIndex: 'talkTime',
          align: 'center',
        },
        {
          title: '操作',
          width: 250,
          align: 'center',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' },
        },
      ],
      pageFilter: {
        pageNo: 1,
        pageSize: 10,
      },
      pageData: {},
      num: 0,
      personId: this.$store.state.holographicArchives.routeObjData.sjskId,
    }
  },
  methods: {
    getRouter() {
        this.pageFilter.id = this.$store.state.holographicArchives.routeObjData.sjskId
        this.onQuery()
    },
    onQuery() {
      this.pageFilter.pageNo = 1
      this.refreshTable()
    },
    onTableChange(pagination, pageFilter, sorter) {
      let keyMap = { currentPage: 'pageNo' }
      let paginations = Object.keys(pagination).reduce((newData, key) => {
        let newKey = keyMap[key] || key
        newData[newKey] = pagination[key]
        return newData
      }, {})
      this.pageFilter = Object.assign({}, this.pageFilter, paginations)
      this.refreshTable()
    },
    refreshTable() {
      this.loading = true
      educationTalk.intHistory(this.pageFilter).then((res) => {
        if (res.success) {
          this.pageData = res.result.list
          this.num = res.result.num
          this.loading = false
        } else {
          this.loading = false
        }
      })
        .catch((e) => {
          this.loading = false
          this.$message.warn('请求失败！')
        })
    },

  },
}
</script>
<style lang="less" scoped>
.btnBox {
  position: absolute;
  right: 24px;
  top: 80px;
}
</style>
